/**
 * Created by Administrator on 2017/9/26.
 */

/**
 * 重新登录
 * */
function againLogin() {
    
}

/**
 * location.search
 *传入key，返回location.search中对应的value
 *截取出当前url后面的id
 * */
function locationSearcher(key) {
    var search = location.search.split('?');
    if(search.length>1){
        var params = search[1].split('&');
        for(var i=0;i<params.length; i++){
            var item = params[i].split('=');
            var k = item[0];
            if(key == k){
                return item[1];
            }
        }
    }
    return null;
}
/**
 * 图片懒加载
 * */

function lazyImg() {
    new auiLazyload({
        errorImage:'static/img/errorimg.png'
    });
}


/**
 * 支付方法
 * @inputSale 输入的金额或者拉起微信支付宝支付时的金额
 * @redPacketSale 红包满减的金额。
 * @method  支付的方式  1微信  2支付宝
 * @lotteryMethod  支付回调成功之后调用js的方法名
 * @shopId 店铺id
 * @shopName 店铺名
 * @type 区分订单是转一转还是普通订单，用于区分分红
 *
 * */
function goPay(inputSale,redPacketSale,method,lotteryMethod,shopId,shopName,type) {

    var payData = {
        method:method,
        inputSale:inputSale,
        redPacketSale:redPacketSale,
        lotteryMethod:lotteryMethod,
        shopId:shopId,
        shopName:shopName,
        type:type
    };
    var ua = navigator.userAgent.toLowerCase();
    if (/iphone|ipad|ipod/.test(ua)) {
        iosPullpay(payData);
    } else {
        androidPullPay(JSON.stringify(payData));
    }
}

//Android 拉取支付
function androidPullPay(param) {
    window.huifa.pullPay(param);
}

//ios 拉取支付
function iosPullpay(param) {
    window.webkit.messageHandlers.pullPay.postMessage(param);
}


/*模拟弹窗*/
var dialog={};
dialog.alert = function (data) {
    data.type = 'alert';
    data.width = '270px';
    data.title = data.title ? data.title : '温馨提示';
    data.okText = data.okText ? data.okText : "知道了";
    return $.dialog(data);
};

dialog.confirm = function (data) {
    data.type = 'confirm';
    data.width = '270px';
    return $.dialog(data);
};

dialog.loading = function (con) {
    return $.dialog({content: con, titleIcon: "load", width: '230px', type: "loading"});
};

dialog.tusiSuccess = function (con) {
    return $.dialog({content: con, titleIcon: "success", width: '230px', type: "tusi", time: 1000});
};

dialog.tusiError = function (con , time) {
    time = time ? time : 3000;
    return $.dialog({content: con, titleIcon: "error", width: '230px', type: "tusi", time: time});
};

dialog.tusi = function (con) {
    return $.dialog({content: con, width: '230px', type: "tusi", time: 1000});
};

